package com.zork.cmdb.webapi.common.exception.handler;

import com.zork.cmdb.webapi.common.response.ResponseEntityEnum;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenjh
 * @date 2018/5/17
 * @description
 */
@RestController
public class ResourceNotFoundController implements ErrorController {

    private static final String ERROR_PATH = "/error";

    @RequestMapping(value = ERROR_PATH)
    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    public ResponseEntityEnum handleError() {
        return ResponseEntityEnum.RESOURCE_NOT_FOUND_ERROR;
    }

    @Override
    public String getErrorPath() {
        return ERROR_PATH;
    }
}